package com.gxa.community.admin.controller;

import com.gxa.community.admin.service.OperateFullService;
import com.gxa.community.core.pojo.vo.FullAddVo;
import com.gxa.community.core.utils.CodingUtils;
import com.gxa.community.core.utils.R;
import org.hibernate.validator.constraints.Length;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/fullreduction")
public class FullRecordController {
    @Autowired
    private OperateFullService operateFullService;


    @GetMapping("/fullreductions")
    public R getFullReductions(@NotNull int page, @NotNull int size){
        System.err.println(page+"  "+size);
        R r = operateFullService.queryFull(page,size);
        return r;
    }

    @GetMapping("/preaddfull")
    public R PreAddFull(){
        String s = CodingUtils.RandomNum();
        return R.ok().put("data",s);
    }

    @PostMapping("/addfullreduction")
    public R addFullReductions(@RequestBody  FullAddVo fullAddVo){
        R r = operateFullService.addFull(fullAddVo);
        return r;
    }


    @DeleteMapping("/delfullreduction")
    public R delFullReductions(@NotNull String fullNo){
        R r = operateFullService.delFull(fullNo);
        return r;
    }

    @GetMapping("/preeditfullreduction")
    public R preEditReductions(@NotNull String fullNo){
        R r = operateFullService.preEdit(fullNo);
        return r;
    }


    @PutMapping("/putfullreduction")
    public R editFullReductions(@RequestBody  FullAddVo fullAddVo){
        R r = operateFullService.editFull(fullAddVo);
        return r;
    }

    @GetMapping("/fulltext")
    public R queryFullText(String name,
                           @Length(min = -1, max = 2)Integer status,
                           Long startTime, Long endTime, Integer page, Integer size){
        R r = operateFullService.textFull(name,status,startTime,endTime, page,size);
        return r;
    }

}
